## Replication code for Section 1 of the Supplmentary Information for:
##  Abrajano, Elmendorf, and Quinn.
##  "Labels vs. Pictures: Treatment Mode Effects in Experiments About
##   Discrimination." Political Analysis. 
##
## Marisa Abrajano, Christopher Elmendorf, and Kevin Quinn
## 9/24/2017
##



set.seed(5794)

load("./WordsPhotosWide.Rda") ## mydata
mydata$treatment <- NA
mydata$treatment[mydata$xtess223 == "show pictures version of the survey"] <- TRUE
mydata$treatment[mydata$xtess223 == "show words version of the survey"] <- FALSE


mean.int.pict <- mean(mydata$int.mot[mydata$treatment==TRUE], na.rm=TRUE)
mean.int.words <- mean(mydata$int.mot[mydata$treatment==FALSE], na.rm=TRUE)
mean.ext.pict <- mean(mydata$ext.mot[mydata$treatment==TRUE], na.rm=TRUE)
mean.ext.words <- mean(mydata$ext.mot[mydata$treatment==FALSE], na.rm=TRUE)

med.int.pict <- median(mydata$int.mot[mydata$treatment==TRUE], na.rm=TRUE)
med.int.words <- median(mydata$int.mot[mydata$treatment==FALSE], na.rm=TRUE)
med.ext.pict <- median(mydata$ext.mot[mydata$treatment==TRUE], na.rm=TRUE)
med.ext.words <- median(mydata$ext.mot[mydata$treatment==FALSE], na.rm=TRUE)


t.test.out.int <- t.test(mydata$int.mot[mydata$treatment],
                         mydata$int.mot[!mydata$treatment])

t.test.out.ext <- t.test(mydata$ext.mot[mydata$treatment],
                         mydata$ext.mot[!mydata$treatment])



library(Matching)
ks.out.int <- ks.boot(mydata$int.mot[mydata$treatment],
                      mydata$int.mot[!mydata$treatment], nboots=5001)

ks.out.ext <- ks.boot(mydata$ext.mot[mydata$treatment],
                      mydata$ext.mot[!mydata$treatment], nboots=5001)


pdf("MotivContStereo-QQ-treatment.pdf", height=5, width=10)
par(mfrow=c(1,2))
qqplot(mydata$int.mot[mydata$treatment], mydata$int.mot[!mydata$treatment],
       xlab="Quantiles of Internal Motivation for Photos Arm",
       ylab="Quantiles of Internal Motivation for Labels Arm")
abline(0,1, col="red")


qqplot(mydata$ext.mot[mydata$treatment], mydata$ext.mot[!mydata$treatment],
       xlab="Quantiles of External Motivation for Photos Arm",
       ylab="Quantiles of External Motivation for Labels Arm")
abline(0,1, col="red")

dev.off()

